define(['jquery','jquery-weui','weui','common'], function ($,JqueryWuei,Weui) {
    var Controller = {
        index: function () {
            var storagename='student';
            // console.log(Config.user);
            // if(Config.user)
            // {
            //     var is_sub = Config.user.is_sub;
            // // alert(is_sub);
            //     if(is_sub == 0)
            //         showmark();
            //     else
            //         hidemark();
            // }

            var formdom = [
                {id: 'a_10',name: 'row[a_10]', is_required: 1},
                {id: 'a_11',name: 'row[a_11]', is_required: 1},
                {id: 'a_12',name: 'row[a_12]', is_required: 1},
                {id: 'a_16',name: 'row[a_16]', is_required: 1},

            ];

            getStorage(formdom,storagename);

                // $('body').height($('body')[0].clientHeight);
                // document.addEventListener('mousewheel',handler,{})
            $("#birthday_time").calendar({
                value: ["2000-01-01"],
            });
            $(".datetime-picker").calendar();
            $(".city-picker").cityPicker({
                onChange:function(picker, values, displayValues){
                    // console.log(values);
                    // console.log(displayValues);
                },
                onClose: function (result) {
                    console.log(result);
                    var province = result.value[0];
                    var city = result.value[1];
                    var district = result.value[2];
                    // console.log(province,city,district)
                    if(result.input[0].id == 'family_address')
                    {
                        $("#family_province_code").val(province);
                        $("#family_city_code").val(city);
                        $("#family_district_code").val(district);
                        // $("#college_id").val(result[1].value);
                    }
                    if(result.input[0].id == 'current_address')
                    {
                        $("#current_province_code").val(province);
                        $("#current_city_code").val(city);
                        $("#current_district_code").val(district);
                        // $("#college_id").val(result[1].value);
                    }
                   // var str = result[0].label + '-' + result[1].label + '-' + result[2].label ;

                   //  $("#classes_name").val(str);
                   //  $("#college_name").val(result[0].label);
                   //  $("#year_").val(result[0].value);
                   //  $("#college_id").val(result[1].value);
                   //  $("#classes_id").val(result[2].value);
                   // console.log(result)
               },
            });
            var classdata = [];
            $.ajax({
                    url: '/index/formstudent/getclasses',
                    dataType: 'json',
                    success: function(res){
                        console.log(res);
                        classdata = res;
                    }
            });
            $("#classes_name").focus(function () {
                document.activeElement.blur();
            })

            $(".city-picker").focus(function () {
                document.activeElement.blur();
            })

                // 时间选择器
            $('#classes_name').on('click', function () {
                Weui.picker(classdata, {
                   className: 'custom-classname',
                   container: 'body',
                   onChange: function (result) {
                       console.log(result)
                   },
                   onConfirm: function (result) {
                       var str = result[0].label + '-' + result[1].label  ;

                        $("#classes_name").val(str);
                        $("#year_").val(result[0].value);
                        $("#classes_id").val(result[1].value);
                       console.log(result)
                   },

                   id: 'multiPickerBtn'
                });
            });

            $('input[type=radio][name="row[a_10]"]').change(function() {
                displaydom($("#a_10"),this.value,1);
            });
            $('input[type=radio][name="row[a_11]"]').change(function() {
                displaydom($("#a_11"),this.value,1);
            });
            $('input[type=radio][name="row[a_12]"]').change(function() {
                  displaydom($("#a_12"),this.value,1);
            });
            $('input[type=radio][name="row[a_16]"]').change(function() {
                displaydom($("#a_16"),this.value,1);
            });

                /* form */
            // 约定正则
            var regexp = {
                regexp: {

                }
            };

            // 失去焦点时检测
            Weui.form.checkIfBlur('#form1', regexp);

            // 表单提交
            $('#formSubmitBtn').click(function (event) {
                // event.preventDefault();
                Weui.form.validate('#form1', function (error) {
                    console.log(error);
                    if (!error) {
                        saveStorage(storagename);
                        // var loading = Weui.loading('提交中...');
                        // $.showLoading('提交中...');
                        // setTimeout(function () {
                        //     $.hideLoading();
                        //     $.toast('提交成功!', 3000);
                        // }, 1500);
                    }
                }, regexp);
                // return false;
            });


        }
    }
    return Controller;
})